var _blbanner = 0;//0,1
var is_auto_close = false;
var is_can_skip = false;
var is_top_banner = false;

var is_auto_ads = false;
var is_open_more = false;
var is_open_playprogress = true;
var is_afc_loading_page = false;

window["AD_CONIFG"] = {
    "rewardType": "AdxReward",
    "interType": "AdxReward",
    "gdDataAdChannel": "",
    "gdAdclient": '',
    "gdAfcAdslot": '',
    "AdxAfcId": '',
    "AdxDefineSlot": '',
    "AdxAfcId2": '',
    "AdxDefineSlot2": '',
    "AdxRewardSlot": '',
    "AdxOldAfgUrl": '',
    "bannerType": '',
    "gdBannerclient": '',
    "gdBannerSlot": '',
    "bannerType2": '',
    "gdBannerclient2": '',
    "gdBannerSlot2": '',
    "AdxAfcId3": '',
    "AdxDefineSlot3": '',
};

var _html = '<a id="a_more_game" class="a_more_game">  <img class="img_more_game" style="z-index: 120000;top:20%;height:15vw;width:15vw;position:fixed;-webkit-border-radius: 50%;  border-radius: 50%"></a>'
var _urls = [];

var _temp_urls = getRandomArrayElements(_urls, 5);
var _more_created = 0;

function getRandomArrayElements(arr, count) {
    var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index;
    while (i-- > min) {
        index = Math.floor((i + 1) * Math.random());
        temp = shuffled[index];
        shuffled[index] = shuffled[i];
        shuffled[i] = temp;
    }
    return shuffled.slice(min);
}


function create_more_img() {
    $("body").append(_html);
    setTimeout(change_game_icon, 1000);
}

function change_game_icon() {
    var _i = _more_created % 5;
    _more_created = _more_created + 1;

    $(".a_more_game").attr("href", _temp_urls[_i][1]);
    $(".img_more_game").attr("src", "../../../../gameImage/" + _temp_urls[_i][0]);

    setTimeout(change_game_icon, 7000);
}


function hidden_more_img() {
    $("#a_more_game").hide();
}

function show_more_img() {
    $("#a_more_game").show();
}

function _add_ga() {

    return;
    (function (i, s, o, g, r, a, m) {
            i['GoogleAnalyticsObject'] = r;
            i[r] = i[r] || function () {
                (i[r].q = i[r].q || []).push(arguments)
            }
                ,
                i[r].l = 1 * new Date();
            a = s.createElement(o),
                m = s.getElementsByTagName(o)[0];
            a.async = 1;
            a.src = g;
            m.parentNode.insertBefore(a, m)
        }
    )(window, document, 'script', 'https://www.googletagmanager.com/gtag/js?id=UA-190243678-62', 'ga');
    window.dataLayer = window.dataLayer || [];

    function gtag() {
        dataLayer.push(arguments);
    }

    gtag('js', new Date());
    gtag('config', 'UA-190243678-62');
}

function _add_GdJs(callback) {
    var fn = callback || function () {
    };

    if (window["AD_CONIFG"].rewardType == "googleNewAfg" || window["AD_CONIFG"].interType == "googleNewAfg") {

        is_afc_loading_page = false;
        var script = document.createElement("script");
        script.async = true;
        script.setAttribute("data-ad-client", window["AD_CONIFG"].gdAdclient);
        script.setAttribute("data-ad-channel", window["AD_CONIFG"].gdDataAdChannel);
        script.setAttribute("data-ad-frequency-hint", "10s");

        script.onload = function () {
            fn && fn();
            fn = null;
        };
        script.onerror = function () {
        };
        script.src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";
        document.head.appendChild(script);

    } else if (window["AD_CONIFG"].interType == "googleAfc" || window["AD_CONIFG"].bannerType == "googleAfc") {
        var script = document.createElement("script");
        script.async = true;
        script.onload = function () {
            fn && fn();
            fn = null;
        };
        script.onerror = function () {
        };
        script.setAttribute("crossorigin", "anonymous");
        script.src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=" + window["AD_CONIFG"].gdAdclient;
        document.head.appendChild(script);
    }

    if (window["AD_CONIFG"].rewardType == "AdxReward" || window["AD_CONIFG"].interType == "AdxReward" ||
        window["AD_CONIFG"].interType == "AdxINTERSTITIAL" || window["AD_CONIFG"].interType == "AdxAfc" ||
        window["AD_CONIFG"].bannerType == "AdxAfc") {
        var script = document.createElement("script");
        script.async = true;
        script.onload = function () {
            fn && fn();
            fn = null;
        };
        script.onerror = function () {
        };
        script.src = "https://securepubads.g.doubleclick.net/tag/js/gpt.js";
        document.head.appendChild(script);
    }

    if (window["AD_CONIFG"].rewardType == "AdxOldAfg" || window["AD_CONIFG"].interType == "AdxOldAfg") {
        var script = document.createElement("script");
        script.async = true;
        script.onload = function () {
            fn && fn();
            fn = null;
        };
        script.onerror = function () {
        };
        script.src = "//imasdk.googleapis.com/js/sdkloader/ima3.js";
        document.head.appendChild(script);
    }

}


